package com.ruoyi.shebei.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shebei.domain.MaintenanceWarning;
import com.ruoyi.shebei.service.IMaintenanceWarningService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 保养到期提醒Controller
 * 
 * @author ruoyi
 * @date 2024-07-29
 */
@RestController
@RequestMapping("/shebei/warning")
public class MaintenanceWarningController extends BaseController
{
    @Autowired
    private IMaintenanceWarningService maintenanceWarningService;

    /**
     * 查询保养到期提醒列表
     */
    @PreAuthorize("@ss.hasPermi('shebei:warning:list')")
    @GetMapping("/list")
    public TableDataInfo list(MaintenanceWarning maintenanceWarning)
    {
        startPage();
        List<MaintenanceWarning> list = maintenanceWarningService.selectMaintenanceWarningList(maintenanceWarning);
        return getDataTable(list);
    }

    /**
     * 导出保养到期提醒列表
     */
    @PreAuthorize("@ss.hasPermi('shebei:warning:export')")
    @Log(title = "保养到期提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MaintenanceWarning maintenanceWarning)
    {
        List<MaintenanceWarning> list = maintenanceWarningService.selectMaintenanceWarningList(maintenanceWarning);
        ExcelUtil<MaintenanceWarning> util = new ExcelUtil<MaintenanceWarning>(MaintenanceWarning.class);
        util.exportExcel(response, list, "保养到期提醒数据");
    }

    /**
     * 获取保养到期提醒详细信息
     */
    @PreAuthorize("@ss.hasPermi('shebei:warning:query')")
    @GetMapping(value = "/{warningId}")
    public AjaxResult getInfo(@PathVariable("warningId") Long warningId)
    {
        return success(maintenanceWarningService.selectMaintenanceWarningByWarningId(warningId));
    }

    /**
     * 新增保养到期提醒
     */
    @PreAuthorize("@ss.hasPermi('shebei:warning:add')")
    @Log(title = "保养到期提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MaintenanceWarning maintenanceWarning)
    {
        return toAjax(maintenanceWarningService.insertMaintenanceWarning(maintenanceWarning));
    }

    /**
     * 修改保养到期提醒
     */
    @PreAuthorize("@ss.hasPermi('shebei:warning:edit')")
    @Log(title = "保养到期提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MaintenanceWarning maintenanceWarning)
    {
        return toAjax(maintenanceWarningService.updateMaintenanceWarning(maintenanceWarning));
    }

    /**
     * 删除保养到期提醒
     */
    @PreAuthorize("@ss.hasPermi('shebei:warning:remove')")
    @Log(title = "保养到期提醒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warningIds}")
    public AjaxResult remove(@PathVariable Long[] warningIds)
    {
        return toAjax(maintenanceWarningService.deleteMaintenanceWarningByWarningIds(warningIds));
    }
}
